package controller.admin;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

import dto.admin.DashboardDTO;
import dto.search.ProfileDTO;
import entity.Profile;

import persistence.ProfileDAO;

@ManagedBean(name = "dashboardController")
@SessionScoped
public class DashboardController implements Serializable {

	private static final long serialVersionUID = 880612544635691746L;
	
	public DashboardDTO getCounts(DashboardDTO dto) throws Exception{
		ProfileDAO dao=new ProfileDAO();
		List<Long> list=dao.getCounts(dto.getTenantId());
		dto.setLstWkRecCrtCnt(list.get(0));
		dto.setLstMnthRecCrtCnt(list.get(1));
		dto.setLstYrRecCrtCnt(list.get(2));
		dto.setLstWkRecUpdtCnt(list.get(3));
		dto.setLstMnthRecUpdtCnt(list.get(4));
		dto.setLstYrRecUpdtCnt(list.get(5));
		return dto;
	}

	public List<ProfileDTO> findAll(String tenantID) throws Exception {
		ProfileDAO dao=new ProfileDAO();
		List<Profile> list=dao.search("from Profile");
		List<ProfileDTO> profileDTOList=new ArrayList<ProfileDTO>();
		for(Profile profile:list){
			ProfileDTO profileDTO =new ProfileDTO();
			profileDTO.setAboutself(profile.getAboutself());
			profileDTO.setAddress(profile.getAddress());
			profileDTO.setAge(profile.getAge());
			profileDTO.setBirthplace(profile.getBirthplace());
			profileDTO.setComplexion(profile.getComplexion());
			profileDTO.setDob(profile.getDob());
			profileDTO.setEducation(profile.getEducation());
			profileDTO.setEducationlevel(profile.getEducationlevel());
			profileDTO.setEmail(profile.getEmail());
			profileDTO.setFathername(profile.getFathername());
			profileDTO.setFatherprofession(profile.getFatherprofession());
			profileDTO.setFirstname(profile.getFirstname());
			profileDTO.setGender(profile.getGender());
			profileDTO.setHeight(profile.getHeight());
			profileDTO.setIncome(profile.getIncome()+"");
			profileDTO.setLastname(profile.getLastname());
			profileDTO.setMaritalstatus(profile.getMaritalstatus());
			profileDTO.setMaternalgotram(profile.getMaternalgotram());
			profileDTO.setMobileno(profile.getMobileno());
			profileDTO.setMothername(profile.getMothername());
			profileDTO.setMotherprofession(profile.getMotherprofession());
			profileDTO.setOccupation(profile.getOccupation());
			profileDTO.setPaternalgotram(profile.getPaternalgotram());
			profileDTO.setRasi(profile.getRasi());
			profileDTO.setReccrtts(profile.getReccrtts());
			profileDTO.setReclstupdatets(profile.getReclstupdatets());
			profileDTO.setStar(profile.getStar());
			profileDTO.setTenantid(profile.getTenantid());
			profileDTO.setVideoUrl("http://www.youtube.com/v/XGSy3_Czz8k");
			profileDTOList.add(profileDTO);
		}
		return profileDTOList;
	}
}
